package util;

import java.util.Date;

import utils.DateUtil;
import utils.FileUtil;

public class LogUtil {

	private static boolean FLAG = false;
	private static String PATH = null;
	private static String LINE = null;
	private static String SIGN = "gateway";

	static {
		if ("linux".equalsIgnoreCase(System.getProperty("os.name"))) {
			PATH = "/usr/logs/" + SIGN;
			LINE = "\n";
			FLAG = false;
		} else {
			PATH = "c:/logs/" + SIGN;
			LINE = "\r\n";
			FLAG = true;
		}
	}

	public static void log(String type, String name, String info) {
		if (FLAG) {
			System.out.println(info);
		}
		String filePath = PATH + "/" + type + "/";
		String fileName = name;
		String fileInfo = DateUtil.format(new Date(), "HHmmss") + " " + info + LINE;
		try {
			FileUtil.append(filePath, fileName, fileInfo);
		} catch (Exception e) {
			e.printStackTrace();
			System.out.println("logging failure");
		}
	}
	
	public static void risk(String info) {
		log("risk", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}

	public static void enter(String info) {
		log("enter", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void balance(String info) {
		log("balance", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void canel(String info) {
		log("canel", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void check(String info) {
		log("check", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void deposit(String info) {
		log("deposit", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void force(String info) {
		log("force", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void freeze(String info) {
		log("freeze", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void fresh(String info) {
		log("fresh", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void logic(String info) {
		log("logic", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}

	public static void penalty(String info) {
		log("penalty", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void refund(String info) {
		log("refund", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void refuse(String info) {
		log("refuse", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void reject(String info) {
		log("reject", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void remedy(String info) {
		log("remedy", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void retun(String info) {
		log("retun", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void revoke(String info) {
		log("revoke", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void settle(String info) {
		log("settle", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void thaw(String info) {
		log("thaw", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void unity(String info) {
		log("unity", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void verify(String info) {
		log("verify", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void notify(String info) {
		log("notify", DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}

	public static void agency(String sign, String info) {
		log(sign, DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void schedule(String sign, String info) {
		log(sign, DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}
	
	public static void receive(String sign, String info) {
		log(sign, DateUtil.format(new Date(), "yyyy_MM_dd"), info);
	}

	public static void main(String[] args) {
		enter("333");
	}

}
